<%@ page contentType="text/html;charset=UTF-8" language="java" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=gbk" />
	<title>易买网 - 首页</title>
	<link type="text/css" rel="stylesheet" href="css/style.css" />
	<script type="text/javascript" src="scripts/function.js"></script>
</head>
<body>
<%@include file="nav.jsp"%>
<div id="position" class="wrap">
	您现在的位置：<a href="productSelectByPage">易买网</a> &gt; <a href="product-list.jsp">图书音像</a> &gt; 图书
</div>
<div id="main" class="wrap">
	<%@include file="left.jsp"%>
	<div id="product" class="main">
		<h1>${product.ep_id}--${product.ep_name}</h1>
		<div class="infos">
			<div class="thumb">
				<img width="200px" height="200px" src="data:image/jpeg;base64,${image}" name="image"/></div>
			<div class="buy">
				<p>商城价：<span class="price">￥${product.ep_price}</span></p>
				<p>库　存：有货(库存${product.ep_stock}件)			  </p>
				<div class="button">
					<input type="button" id="addToCartButton" value=""/>
					<a href="shopcarAdd?id=${product.ep_id}">放入购物车</a>
				</div>
			</div>
			<div class="clear"></div>
		</div>
		<div class="introduce">
			<h2><strong>商品详情</strong></h2>
			<div class="text">
				${product.ep_description}<br />
			</div>
		</div>
	</div>
	<div class="clear"></div>
</div>
<div id="footer">
	Copyright &copy; 2022 卓京教育 All Rights Reserved. 湘ICP证1001号
</div>
</body>
</html>
<script>
	document.getElementById('addToCartButton').addEventListener('click', function() {
		var xhr = new XMLHttpRequest();
		xhr.open('GET', 'shopcarAdd?id=${product.ep_id}', true);
		xhr.onreadystatechange = function() {
			window.location.href = 'shopcarList';
		};
		xhr.send();
	});

</script>
